package mofei.concurrent.task;


/**
 * @author mofei@staff.weibo.com
 * @date 2019/2/22 2:34 PM
 */
public class BlockedTask4 implements Runnable {

    @Override
    public void run() {
        try{
            BlockedTask3.lock2.lock();
            System.out.println("获取lock2锁，进入休眠");
            Thread.sleep(1000*5);
            System.out.println("lock2苏醒，开始竞争lock1");
            BlockedTask3.lock1.lock();
            System.out.println("已获取lock1");
        }catch (Exception e){
            e.printStackTrace();
        } finally{
            BlockedTask3.lock1.unlock();
            BlockedTask3.lock2.unlock();
        }

    }
}
